/*
 * solveEquationSystem.cpp
 *
 *  Created on: Jun 22, 2011
 *      Author: Gilad & Yotam
 */

#include "solveEquationSystem.h"
#include "mtm.h"

SolveEquationSystem::SolveEquationSystem(int id, int priority, const Matrix& a,
		const Matrix& b) :
	Job(id, priority, a, b) {
}
Matrix SolveEquationSystem::execute() {
	/*
	 * we only need to make sure the matrix b has one column.
	 * the rest will be done automatically through the matrix class
	 */
	try {
		if (b.columns() == 1) {
			return (a.inverse() * b);
		} else {
			throw Job::JobFailed();
		}
	} catch (MatrixExceptions::MatrixException&) {
		throw Job::JobFailed();
	}
}
